<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="">
        <el-col :span="6">
          <el-form-item prop="timeScope">
            <el-select v-model="formInline.dateType" placeholder="请选择时间范围">
              <el-option label="新增时间" :value="0"></el-option>
              <el-option label="删除时间" :value="1"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              :default-time="['00:00:00', '23:59:59']"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :picker-options="pickerDayStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item prop="keywords" class="with-pre-select">
        <el-input v-model="formInline.keywords" @keyup.enter.native="$emit('on-filter',formInline)">
          <el-select v-model="formInline.searchType" slot="prepend">
            <el-option label="账户名" value="1"></el-option>
            <!--<el-option label="姓名" value="2"></el-option>-->
            <el-option label="银行卡号" value="3"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      <el-form-item label="账户类型" prop="userType">
        <el-select v-model="formInline.userType" placeholder="请选择账户类型">
          <el-option
            v-for="item in consts.ACCOUNT_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="银行名称" prop="bankId">
        <el-select v-model="formInline.bankId" placeholder="请选择状态">
           <el-option
            :label="'全部'"
            :key="consts.ALL"
            :value="undefined"
          ></el-option>
          <el-option
            v-for="item in consts.PAYEE_BANKS"
            v-if="item.value !== 16"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择状态">
          <el-option
            v-for="item in consts.BANK_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {getWithdrawShopList} from '@/services/api/withdraw'
  import {form, pickerOption} from '@/build'

  export default {
    name: "logs-filter",
    mixins: [form, pickerOption],
    data() {
      const fromDate = moment().format('YYYY-MM-DD 00:00:00');
      const endDate = moment ().format('YYYY-MM-DD 23:59:59');
      return {
        withdrawShopList: [],
        formInline: {
          time: [
            fromDate,
            endDate],
          dateType: 0,
          searchType: undefined,
          keywords: undefined,
          userType: undefined,
          bankId: undefined,
          status: undefined,
        },

      }
    },
    methods: {
      selfResetForm(formName) {
        this.resetForm(formName)
        this.$parent.getAll()
      }
    },
    mounted() {
      this.bindGet(getWithdrawShopList, 'withdrawShopList', {
        format: (data) => {
          console.log(data)
          return data.list
        }
      });
      this.getAll()
    }
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
